<!-- 租户用户-->
<template>
  <BasicTable @register="registerTable">
    <!-- <template #tableTitle>
		</template> -->
    <template #action="{ record }">
      <TableAction :actions="getTableAction(record)"/>
    </template>
  </BasicTable>
  <UserDetails @register="registerDetailsDrawer"/>
</template>

<script lang="ts" name="tenant-user-list" setup>
//ts语法
import {ActionItem, BasicTable, TableAction} from '/@/components/Table'
import UserDetails from './UserDetails.vue';
import {useDrawer} from '/@/components/Drawer';
import {useListPage} from '/@/hooks/system/useListPage'
import {useMessage} from '/@/hooks/web/useMessage';
import {columns, searchFormSchema} from './user.data';
import {list} from './user.api';
// import { usePermission } from '/@/hooks/web/usePermission'
// const { hasPermission } = usePermission();

const { createMessage, createConfirm } = useMessage();

const [registerDetailsDrawer, { openDrawer: openDetailsDrawer }] = useDrawer();

// 列表页面公共参数、方法
const { prefixCls, tableContext } = useListPage({
  designScope: 'tenant-user-list',
  tableProps: {
    title: '租户用户',
    api: list,
    bordered: false,
    columns: columns,
    size: 'small',
    formConfig: {
      schemas: searchFormSchema,
    },
    actionColumn: {
      width: 110,
      title: '操作',
      dataIndex: 'action',
      fixed: 'right',
      slots: { customRender: 'action' },
    },
    beforeFetch: (params) => {
      return Object.assign({ 'column': 'createTime', 'order': "desc" }, params)
    },
  }
})


//注册table数据
const [registerTable, { reload, updateTableDataRecord }, { rowSelection, selectedRowKeys }] = tableContext

/**
 * 详情
*/
async function handleDetail(record: Recordable) {
  openDetailsDrawer(true, {
    record,
    isUpdate: true,
    showFooter: false,
  });
}

/**
 * 操作栏
 */
function getTableAction(record): ActionItem[] {
  return [
    {
      label: '详情',
      onClick: handleDetail.bind(null, record)
    }
  ]
}
</script>

<style scoped></style>
